#!usr/bin/python
# -*= coding: UTF-8 -*-
def myGen():
    print('生成器被执行！')
    yield 1
    yield 2

myG = myGen()
print(next(myG))
print(next(myG))

for i in myGen():
    print(i)

def libs():
    a = 0
    b = 1
    while True:
        a, b = b, a + b
        yield a

for each in libs():
    if each > 100:
        break
    print(each, end = ' ')

a = [i for i in range(100) if not (i % 2) and (i % 3)]
print()
print('a = ', a)

b = {i: i % 2 == 0 for i in range(10)}  #通过字典形式，判断0-9这10个数是否为偶数
print(b)

c = {i for i in [1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 3, 2, 1]}
print(c)

d = "i for i in 'I love python!"
e = (i for i in range(10))
print(e)

for each in e:
    print(each)

print(sum((i for i in range(100) if i % 2))) #把100内不能被2整除的数加起来
print(sum((i for i in range(100) if i % 2)))




